#define _CRT_SECURE_NO_WARNINGS 1
    /*int n = 0;
    long long i = 0;
    scanf("%d", &n);
    double a[20] = { 0 }, s = 0, ave = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%lf", &a[i]);
        s += a[i];
    }
    ave = s * 1.0 / n;
    for (i = 0; i < n; i++)
    {
        if (a[i] > ave)
        {
            a[i] = a[i] * 0.9;
        }
        if (i == 0)
        {
            printf("%.1lf", a[0]);
        }
        else
            printf(" %.1lf", a[i]);
    }*/
    int prime(int n)
    {
        int i = 0;
        for (i = 0; i <= sqrt(n); i++)
        {
            if (n % i == 0)
            {
                return 0;
            }
            return 1;
        }
    }

#include <stdio.h>
#include <math.h>
#include <string.h>
    int main()
    {
        char a[90] = { 0 };
        gets(a);
        int n = 0;
        scanf("%d", &n);
        int i = 0, max = 0, min = 10000, l = 0, j = 0, s = 0, f = 0;
        l = strlen(a);
        int index1 = 0, index2 = l - 1;
        for (i = 0; i < l - 1; i++)
        {
            s = 0;
            for (j = i; j < i + n; j++)
            {
                s = s * 10 + a[j] - '0';
            }
            if (prime(s) == 1)
            {
                f = 1;
                if (s >= max)
                {
                    max = s;
                    index1 = i;
                }
                if(s <= min)
                {
                    min = s;
                    index2 = i;
                }
            }
            else
                continue;
        }
        if (f == 0)
        {
            printf("NONE");
        }
        else
            printf("max_prime=%d,last start position=%d\nmin_prime=%d,last start position=%d", max, index1, min, index2);

        return 0;
    }
